package com.buddy.qreport.template.tpls.pie.doughnut;

import com.buddy.qreport.template.IReportTemplate;
import com.buddy.qreport.template.ReportDataDimension;
import com.buddy.qreport.template.annotation.ReportTemplate;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@ReportTemplate(type = IReportTemplate.TYPE_NAME_PIE)
public class DoughnutPieReportTemplate implements IReportTemplate {

    private String demo_js ;

    private List<ReportDataDimension> reportDataDimensions;

    public DoughnutPieReportTemplate() {

        reportDataDimensions = new ArrayList<>(2);

        reportDataDimensions.add(new ReportDataDimension("图例", "legend",false));
        reportDataDimensions.add(new ReportDataDimension("数据","data", false));

        demo_js =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/pie/doughnut/demo.js")))
                .lines().parallel().collect(Collectors.joining("\n"));

    }

    @Override
    public String getName() {
        return "doughnut_pie";
    }

    @Override
    public String getDescription() {
        return "洋葱圈饼图";
    }

    @Override
    public String getDemoJs() {
        return demo_js;
    }

    @Override
    public List<ReportDataDimension> getDataDimensions() {
        return reportDataDimensions;
    }
}
